package com.adprof.demo.natives.viewholders;

/**
 * ViewHolder数据绑定工具类
 * 提供统一的数据绑定方法，避免代码重复
 */
public class ViewHolderDataBinder {

    /**
     * 绑定卡片内容数据
     */
    public static void bindCardContent(CardViewHolder holder, int position) {
        String[] icons = {"📱", "💻", "🎮", "📚", "🎵", "🎬", "🏃", "🍕"};
        String[] titles = {"科技资讯", "编程学习", "游戏推荐", "读书分享", "音乐推荐", "电影评论", "健身指南", "美食分享"};
        String[] subtitles = {"最新科技动态", "编程技巧分享", "热门游戏推荐", "好书推荐", "音乐推荐", "电影评论", "健身指导", "美食制作"};
        
        int index = position % icons.length;
        holder.iconText.setText(icons[index]);
        holder.titleText.setText(titles[index]);
        holder.subtitleText.setText(subtitles[index]);
        holder.contentText.setText("这是第" + position + "个精彩内容，展示了丰富的信息和美观的布局设计。");
        holder.timeText.setText((position % 24) + "小时前");
        holder.likeText.setText("👍 " + (position * 3 + 12));
        holder.commentText.setText("💬 " + (position * 2 + 5));
    }

    /**
     * 绑定图片内容数据
     */
    public static void bindImageContent(ImageViewHolder holder, int position) {
        String[] avatars = {"👤", "👨‍💻", "👩‍🎨", "👨‍🍳", "👩‍🏫", "👨‍🎓"};
        String[] authors = {"摄影师小王", "设计师小李", "美食家小张", "老师小陈", "学生小刘", "创作者小赵"};
        
        int index = position % avatars.length;
        holder.avatarText.setText(avatars[index]);
        holder.authorText.setText(authors[index]);
        holder.titleText.setText("精彩图片内容 " + position);
        holder.descText.setText("这是一张精美的图片，展示了丰富的内容和创意设计。");
        if (holder.timeText != null) {
            holder.timeText.setText((position % 12 + 1) + "小时前");
        }
        holder.likeCount.setText("❤️ " + (position * 5 + 128));
        holder.commentCount.setText("💬 " + (position * 3 + 23));
    }

    /**
     * 绑定视频内容数据
     */
    public static void bindVideoContent(VideoViewHolder holder, int position) {
        String[] channels = {"📺", "🎬", "🎮", "📚", "🏃", "🍳"};
        String[] channelNames = {"科技频道", "电影频道", "游戏频道", "教育频道", "健身频道", "美食频道"};
        
        int index = position % channels.length;
        holder.channelAvatar.setText(channels[index]);
        holder.channelName.setText(channelNames[index]);
        holder.videoTitle.setText("精彩视频内容 " + position);
        holder.videoDesc.setText("这是一个精彩的视频内容，展示了丰富的视觉效果和创意设计。");
        holder.viewCount.setText((position * 1000 + 12000) + "次观看");
        holder.durationText.setText("0" + (position % 5 + 1) + ":3" + (position % 10));
        holder.likeCount.setText("👍 " + (position * 8 + 256));
        holder.commentCount.setText("💬 " + (position * 4 + 45));
    }

    /**
     * 绑定新闻内容数据
     */
    public static void bindNewsContent(NewsViewHolder holder, int position) {
        String[] sources = {"📰 新闻源", "📺 电视台", "📱 科技网", "🌍 国际新闻", "🏠 本地新闻"};
        String[] titles = {"重要新闻标题", "科技突破消息", "经济动态更新", "社会热点事件", "国际要闻速递"};
        String[] summaries = {"这是一条重要的新闻摘要，包含了关键信息和重要内容。", 
                             "科技领域的最新突破，将改变我们的生活方式。",
                             "经济形势的最新变化，影响市场走向。",
                             "社会关注的热点事件，引发广泛讨论。",
                             "国际局势的最新发展，影响全球格局。"};
        
        int index = position % sources.length;
        holder.newsTitle.setText(titles[index]);
        holder.newsSummary.setText(summaries[index]);
        holder.sourceText.setText(sources[index]);
        holder.timeText.setText((position % 12 + 1) + "小时前");
    }

    /**
     * 绑定产品内容数据
     */
    public static void bindProductContent(ProductViewHolder holder, int position) {
        String[] titles = {"精选产品推荐", "智能设备新品", "时尚潮流单品", "家居生活好物", "数码科技产品", "运动健身装备"};
        String[] descriptions = {"这是一个优质的产品，具有出色的性能和设计。", 
                                "智能科技产品，提升生活品质。",
                                "时尚潮流单品，展现个性魅力。",
                                "家居生活好物，让生活更美好。",
                                "数码科技产品，引领科技潮流。",
                                "运动健身装备，助力健康生活。"};
        
        int index = position % titles.length;
        holder.productTitle.setText(titles[index]);
        holder.productDesc.setText(descriptions[index]);
        holder.priceText.setText("¥" + (position * 50 + 299));
        holder.ratingText.setText("⭐ " + (4.0 + (position % 10) * 0.1));
        holder.salesText.setText("已售 " + (position * 1000 + 12000));
    }
}
